import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Log {
    private static final String LOG_FILE = "system.log";
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static void record(String operationType, String details, String operator) {
        try (PrintWriter out = new PrintWriter(new FileWriter(LOG_FILE, true))) {
            String log = String.format("[%s] 操作类型: %s, 操作人: %s, 详情: %s",
                    sdf.format(new Date()), operationType, operator, details);
            out.println(log);
        } catch (IOException e) {
            System.err.println("日志记录失败: " + e.getMessage());
        }
    }
}